<html lang="zh-cn">
<head>
{% include "tdm_include_head_template.html" %}

<script type="text/javascript">
  $("#city_select").change(function() {
    window.location.href="/tdm/admin/server/"+$("#city_select").val();
  });
  $("#venue_select").change(function() {
    window.location.href="/tdm/admin/server/"+$("#city_select").val()+"/"+$("#venue_select").val();
  })
</script>

</head>

<body class="theme-blue">
{% include "tdm_include_navbar_template.html" %}

<div class="container">
  <br/>
  {% include "tdm_include_error_template.html" %}

  {% include "tdm_include_admin_page_template.html" %}

  <div class="form-context">
  <form name="venue_form" class="form-horizontal" role="form" action="/tdm/admin/server/{{view_city.name}}/{{view_venue.name}}/" method="post">
    <div class="row">
      <div class="col-md-3">
        <select name="city_select" id="city_select" class="form-control">
          {% for city in city_all %}
          <option value="{{city.name}}" {% ifequal city.name view_city.name %}selected="selected"{% endifequal %}>{{city.name}}</option>
          {% endfor %}
        </select>
      </div>
      <div class="col-md-3">
        <select name="venue_select" id="venue_select" class="form-control">
          {% for venue in venue_all %}
          <option value="{{venue.name}}" {% ifequal venue.name view_venue.name %}selected="selected"{% endifequal %}>{{venue.name}}</option>
          {% endfor %}
        </select>
        <input type="hidden" name="venue_id" value="{{view_venue.venue_id}}">
      </div>
    </div>
    <br>
    <table id="ctmdev_table" class="table table-hover">
      <tr>
        <th>服务器ID</th>
        <th>服务器IP</th>
        <th>主机名</th>
        <th>设备类型</th>
        <th>位置</th>
        <th>备注</th>
        <td>
          <button name="op" value="srvdev_del" type="submit" class="btn btn-primary btn-sm">删除</button>
        </td>
      </tr>
      {% for srvdev in srvdev_all %}
      <tr>
        <td>{{srvdev.devid}}</td>
        <td>{{srvdev.ip}}</td>
        <td>{{srvdev.hostname}}</td>
        <td>{{srvdev.dev_type}}</td>
        <td>{{srvdev.location}}</td>
        <td>{{srvdev.memo}}</td>
        <td>
          <input type="checkbox" name="srvdev_list" value="{{srvdev.devid}}">
        </td>
      </tr>
      {% endfor %}
      <tr>
        <td>
          <label for="devid" class="sr-only">服务器ID</label>
          <input name="devid" type="text" class="form-control" id="devid" placeholder="服务器ID">
        </td>
        <td>
          <label for="ip" class="sr-only">服务器IP</label>
          <input name="ip" type="text" class="form-control" id="ip" placeholder="服务器IP">
        </td>
        <td>
          <label for="port_nr" class="sr-only">主机名</label>
          <input name="port_nr" type="text" class="form-control" id="port_nr" placeholder="主机名">
        </td>
        <td>
          <label for="dev_type" class="sr-only">设备类型</label>
          <input name="dev_type" type="text" class="form-control" id="dev_type" placeholder="设备类型">
        </td>
        <td>
          <label for="location" class="sr-only">位置</label>
          <input name="location" type="text" class="form-control" id="location" placeholder="位置">
        </td>
        <td>
          <label for="memo" class="sr-only">备注</label>
          <input name="memo" type="text" class="form-control" id="memo" placeholder="备注">
        </td>
        <td><button name="op" value="srvdev_add" type="submit" class="btn btn-primary btn-sm">添加</button></td>
      </tr>
    </table>
  </form>
  </div>

  {% include "tdm_include_footer_template.html" %}
</div>
</body>
</html>